<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:template match="/">
		<infopost-request>
			<xsl:for-each select="ABCB2I">
				<request-head>
					<xsl:for-each select="Header">
						<trans-id>
							<xsl:value-of select="SerialNo" />
						</trans-id>
						<trans-date>
							<xsl:value-of select="TransDate" />
						</trans-date>
						<trans-time>
							<xsl:value-of select="TransTime" />
						</trans-time>
						<bank>203</bank>
						<trans-type>102</trans-type>
						<insu-id>
							<xsl:value-of select="CorpNo" />
						</insu-id>
						<area>
							<xsl:value-of select="ProvCode" />
						</area>
						<branch />
						<post>
							<xsl:value-of select="BranchNo" />
						</post>
						<agency-hand>
							<xsl:value-of select="Tlid" />
						</agency-hand>
						<xsl:call-template name="sourceTypeCode">
							<xsl:with-param name="srcCode" select="EntrustWay" />
						</xsl:call-template>
						<authorized />
					</xsl:for-each>
				</request-head>
				<request-newbiz>
					<xsl:for-each select="App">
						<xsl:for-each select="Req">
							<request-underwriting>
								<application>
									<bank-account>
										<xsl:value-of select="PayAccount" />
									</bank-account>
									<account-name>
										<xsl:value-of select="AccName" />
									</account-name>
									<bank-code>203</bank-code>
									<account-type>7</account-type>
								</application>
							</request-underwriting>
							<request-policy-issue>
								<uw-trans-id>
									<xsl:value-of select="ApplySerial" />
								</uw-trans-id>
								<premium>
									<xsl:if test=" PayAmt != '' ">
										<xsl:value-of select="PayAmt" />
									</xsl:if>
								</premium>
								<apply-code>
									<xsl:value-of select="PolicyNo" />
								</apply-code>
								<invoice-code />
								<print-code />
							</request-policy-issue>
						</xsl:for-each>
					</xsl:for-each>
				</request-newbiz>
			</xsl:for-each>
		</infopost-request>
	</xsl:template>
	<xsl:template name="sourceTypeCode">
		<xsl:param name="srcCode" />
		<xsl:choose>
			<xsl:when test="$srcCode = '01'">
				<source-type>1</source-type>
			</xsl:when>
			<xsl:when test="$srcCode = '04'">
				<source-type>8</source-type>
			</xsl:when>
			<xsl:otherwise>
				<source-type>
					<xsl:value-of select="$srcCode" />
				</source-type>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
